package com.han.hotelplat.dao.systemuser;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.han.hotelplat.comm.base.BaseDAO;
import com.han.hotelplat.pojo.systemuser.Permission;
import com.han.hotelplat.pojo.systemuser.Resource;
import com.han.hotelplat.pojo.systemuser.Systemuser;

@Repository
public class SystemuserDao extends BaseDAO<Systemuser>{

	public Systemuser findUserByUsername(String username) {
		List<Systemuser> li = findByProperty("username", username);
		return li.size() == 0?null:li.get(0);
	}

	public Systemuser findUserByTel(String tel) {
		List<Systemuser> li = findByProperty("tel", tel);
		return li.size() == 0?null:li.get(0);
	}

	public Systemuser findUserByUserId(String userid) {
		List<Systemuser> li = findByProperty("userid", userid);
		return li.size() == 0?null:li.get(0);
	}

	public List<Permission> findAllPermissions() {
		return findByHQL(" From Permission");
	}

	public List<Resource> findAllResource() {
		return findByHQL(" From Resource");
	}

}
